//
//  Dis_AuthorCell.swift
//  ListenFM
//
//  Created by szq on 2017/8/9.
//  Copyright © 2017年 胡定锋. All rights reserved.
//

import UIKit

class Dis_AuthorCell: UITableViewCell,UICollectionViewDataSource,UICollectionViewDelegate {

    var dataArray = NSMutableArray()
    
    var collectionView: UICollectionView!
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setUpViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    func setUpViews(){
        
        let width = contentView.frame.size.width;
        let height = contentView.frame.size.height;
        
        let authorView = Bundle.main.loadNibNamed("HeaderView", owner: nil, options: nil)?.first as! HeaderView
        authorView.frame = CGRect.init(x: 0, y: 0, width: width, height: 25)
        authorView.titleLabel.text = "主播"
        authorView.titleLabel.font = UIFont.systemFont(ofSize: 15)
        
        let layout = UICollectionViewFlowLayout.init()
        let ySapce = CGFloat(10)
        let widthtemp = (SCR_WIDTH - 1*ySapce)/2-10;
        let heighttemp = CGFloat(70);
        layout.itemSize = CGSize(width:widthtemp, height:heighttemp);
        layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 5);

        collectionView = UICollectionView.init(frame: CGRect.init(x: 0, y: 30, width: width, height: height), collectionViewLayout: layout)
        collectionView.delegate = self;
        collectionView.dataSource = self;
        collectionView.backgroundColor = UIColor.white
        contentView.addSubview(collectionView)
        contentView.addSubview(authorView)
        
        collectionView.register(UINib(nibName:"Dis_AuthorCollectionCell", bundle:nil),forCellWithReuseIdentifier: "Dis_AuthorCollectionCell")
        
    }
    
    override func layoutSubviews() {
        
        let width = contentView.frame.size.width;
        let height = contentView.frame.size.height;
        
        collectionView.frame = CGRect.init(x: 0, y: 30, width: width, height: height)
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return 10//imageArray.count
    }
    
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let cell : UICollectionViewCell?
        
        cell  = collectionView.dequeueReusableCell(withReuseIdentifier: "Dis_AuthorCollectionCell", for: indexPath) as! Dis_AuthorCollectionCell
        
        return cell!
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        
        print(indexPath.row)
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        
    }

}
